import pika
# 1.建立RabbitMQ连接
connection = pika.BlockingConnection(
    pika.ConnectionParameters('127.0.0.1')
)
# 2.声明频道对象
channel = connection.channel()
# 3.声明Hello World的队列
queueName = 'Hello World'
channel.queue_declare(queue=queueName)
# 4.调用Channel的basic_publish方法，往Hello World队列内放入了"您好，世界！"的消息
channel.basic_publish(
    exchange='',
    routing_key=queueName,
    body='您好，世界！'
)
print("发送：您好，世界！")
